<html>
<head><meta charset="utf-8"><title>macros discussion · t-compiler/wg-rustc-dev-guide · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/index.html">t-compiler/wg-rustc-dev-guide</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html">macros discussion</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="170484515"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/170484515" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#170484515">(Jul 09 2019 at 19:45)</a>:</h4>
<p><span class="user-mention" data-user-id="123856">@Vadim Petrochenkov</span> Hi <span aria-label="wave" class="emoji emoji-1f44b" role="img" title="wave">:wave:</span> <br>
I was wondering if you would have a chance sometime in the next month or so to just have a zulip discussion where you tell us (WG-learning) everything you know about macros/expansion/hygiene. We were thinking this could be less formal (and less work for you) than compiler lecture series lecture... thoughts?</p>



<a name="170484561"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/170484561" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#170484561">(Jul 09 2019 at 19:45)</a>:</h4>
<p>The goal is to fill out that long-standing gap in the rustc-guide</p>



<a name="170486732"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/170486732" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#170486732">(Jul 09 2019 at 20:13)</a>:</h4>
<p>Ok, I'm at UTC+03:00 and generally available in the evenings (or weekends).</p>



<a name="170493035"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/170493035" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#170493035">(Jul 09 2019 at 21:43)</a>:</h4>
<p><span class="user-mention" data-user-id="123856">@Vadim Petrochenkov</span> Either of those works for me (your evenings are about lunch time for me :) ) Is there a particular date that would work best for you?</p>



<a name="170493096"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/170493096" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#170493096">(Jul 09 2019 at 21:44)</a>:</h4>
<p><span class="user-group-mention" data-user-group-id="1380">@WG-learning</span> Does anyone else have a preferred date?</p>



<a name="170494319"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/170494319" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#170494319">(Jul 09 2019 at 22:06)</a>:</h4>
<blockquote>
<p>Is there a particular date that would work best for you?</p>
</blockquote>
<p>Nah, not much difference.<br>
(If something changes for a specific day, I'll notify.)</p>



<a name="170499146"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/170499146" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#170499146">(Jul 09 2019 at 23:28)</a>:</h4>
<p>week days are better, but I'd say let's wait for <span class="user-mention" data-user-id="123856">@Vadim Petrochenkov</span> to say when they are ready for it and we can set a date</p>



<a name="170499156"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/170499156" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#170499156">(Jul 09 2019 at 23:29)</a>:</h4>
<p>also, we should record this so ... I guess it doesn't matter that much when :)</p>



<a name="170576428"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/170576428" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#170576428">(Jul 10 2019 at 20:22)</a>:</h4>
<blockquote>
<p>also, we should record this so ... I guess it doesn't matter that much when :)</p>
</blockquote>
<p><span class="user-mention" data-user-id="116266">@Santiago Pastorino</span> My thinking was to just use zulip, so we would have the log</p>



<a name="170576616"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/170576616" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#170576616">(Jul 10 2019 at 20:25)</a>:</h4>
<p><span class="user-mention" data-user-id="123856">@Vadim Petrochenkov</span> <span class="user-group-mention" data-user-group-id="1380">@WG-learning</span>  How about 2 weeks from now: July 24 at 5pm UTC time (if I did the math right, that should be evening for Vadim)</p>



<a name="170576730"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/170576730" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> amanjeev <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#170576730">(Jul 10 2019 at 20:26)</a>:</h4>
<p>i can try and do this but I am starting a new job that week so cannot promise.</p>



<a name="170581615"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/170581615" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#170581615">(Jul 10 2019 at 21:37)</a>:</h4>
<blockquote>
<p><span class="user-mention silent" data-user-id="123856">Vadim Petrochenkov</span> <span class="user-group-mention" data-user-group-id="1380">@WG-learning</span>  How about 2 weeks from now: July 24 at 5pm UTC time (if I did the math right, that should be evening for Vadim)</p>
</blockquote>
<p>works perfect for me</p>



<a name="170581633"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/170581633" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#170581633">(Jul 10 2019 at 21:37)</a>:</h4>
<p><span class="user-mention" data-user-id="198054">@mark-i-m</span> I have access to the compiler calendar so I can add something there</p>



<a name="170581680"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/170581680" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#170581680">(Jul 10 2019 at 21:38)</a>:</h4>
<p>let me know if you want to add an event to the calendar, I can do that</p>



<a name="170581684"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/170581684" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#170581684">(Jul 10 2019 at 21:38)</a>:</h4>
<p>how long it would be?</p>



<a name="170593917"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/170593917" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#170593917">(Jul 11 2019 at 01:11)</a>:</h4>
<blockquote>
<p>let me know if you want to add an event to the calendar, I can do that</p>
</blockquote>



<a name="170593919"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/170593919" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#170593919">(Jul 11 2019 at 01:11)</a>:</h4>
<p>That could be good <span aria-label="+1" class="emoji emoji-1f44d" role="img" title="+1">:+1:</span></p>



<a name="170593974"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/170593974" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#170593974">(Jul 11 2019 at 01:12)</a>:</h4>
<blockquote>
<p>how long it would be?</p>
</blockquote>
<p>Let's start with 30 minutes, and if we need to schedule another we cna</p>



<a name="170853325"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/170853325" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#170853325">(Jul 14 2019 at 23:16)</a>:</h4>
<blockquote>
<p>5pm UTC</p>
</blockquote>
<p>1-2 hours later would be better, 5pm UTC is not evening enough.</p>



<a name="170853332"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/170853332" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#170853332">(Jul 14 2019 at 23:17)</a>:</h4>
<p>How exactly do you plan the meeting to go (aka how much do I need to prepare)?</p>



<a name="170894657"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/170894657" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#170894657">(Jul 15 2019 at 13:52)</a>:</h4>
<blockquote>
<blockquote>
<p>5pm UTC</p>
</blockquote>
<p>1-2 hours later would be better, 5pm UTC is not evening enough.</p>
</blockquote>
<p>Scheduled for 7pm UTC then</p>



<a name="170894736"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/170894736" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#170894736">(Jul 15 2019 at 13:53)</a>:</h4>
<blockquote>
<p>How exactly do you plan the meeting to go (aka how much do I need to prepare)?</p>
</blockquote>
<p>/cc <span class="user-mention" data-user-id="198054">@mark-i-m</span></p>



<a name="170901496"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/170901496" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#170901496">(Jul 15 2019 at 15:07)</a>:</h4>
<p><span class="user-mention" data-user-id="123856">@Vadim Petrochenkov</span> </p>
<blockquote>
<p>How exactly do you plan the meeting to go (aka how much do I need to prepare)?</p>
</blockquote>
<p>My hope was that this could be less formal than for a compiler lecture series, but it would be nice if you could have in your mind a tour of the design and the code</p>
<p>That is, imagine that a new person was joining the compiler team and needed to get up to speed about macros/expansion/hygiene. What would you tell such a person?</p>



<a name="171534846"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171534846" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171534846">(Jul 23 2019 at 16:33)</a>:</h4>
<p><span class="user-mention" data-user-id="123856">@Vadim Petrochenkov</span> Are we still on for tomorrow at 7pm UTC?</p>



<a name="171538051"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171538051" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171538051">(Jul 23 2019 at 17:13)</a>:</h4>
<p>Yes.</p>



<a name="171543193"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171543193" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171543193">(Jul 23 2019 at 18:09)</a>:</h4>
<p><span class="user-mention" data-user-id="123856">@Vadim Petrochenkov</span> <span class="user-mention" data-user-id="198054">@mark-i-m</span> I've added an event on rust compiler team calendar</p>



<a name="171632704"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171632704" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171632704">(Jul 24 2019 at 18:53)</a>:</h4>
<p><span class="user-group-mention" data-user-group-id="1380">@WG-learning</span> <span class="user-mention" data-user-id="123856">@Vadim Petrochenkov</span> Hello!</p>



<a name="171632736"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171632736" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171632736">(Jul 24 2019 at 18:53)</a>:</h4>
<p>We will be starting in ~7 minutes</p>



<a name="171632889"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171632889" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171632889">(Jul 24 2019 at 18:55)</a>:</h4>
<p><span aria-label="wave" class="emoji emoji-1f44b" role="img" title="wave">:wave:</span></p>



<a name="171633143"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171633143" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171633143">(Jul 24 2019 at 18:58)</a>:</h4>
<p>I'm here.</p>



<a name="171633288"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171633288" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171633288">(Jul 24 2019 at 19:00)</a>:</h4>
<p>Cool :)</p>



<a name="171633292"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171633292" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171633292">(Jul 24 2019 at 19:00)</a>:</h4>
<p>hello <span class="user-mention" data-user-id="123856">@Vadim Petrochenkov</span></p>



<a name="171633293"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171633293" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171633293">(Jul 24 2019 at 19:00)</a>:</h4>
<p>Shall we start?</p>



<a name="171633316"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171633316" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171633316">(Jul 24 2019 at 19:00)</a>:</h4>
<p>First off, <span class="user-mention" data-user-id="123856">@Vadim Petrochenkov</span> Thanks for doing this!</p>



<a name="171633344"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171633344" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171633344">(Jul 24 2019 at 19:01)</a>:</h4>
<p>Here's some preliminary data I prepared.</p>



<a name="171633348"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171633348" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171633348">(Jul 24 2019 at 19:01)</a>:</h4>
<p>Below I'll assume <a href="https://github.com/rust-lang/rust/issues/62771" target="_blank" title="https://github.com/rust-lang/rust/issues/62771">#62771</a> and <a href="https://github.com/rust-lang/rust/issues/62086" target="_blank" title="https://github.com/rust-lang/rust/issues/62086">#62086</a> has landed.</p>



<a name="171633372"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171633372" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171633372">(Jul 24 2019 at 19:01)</a>:</h4>
<p>Where to find the code:<br>
libsyntax_pos/hygiene.rs - structures related to hygiene and expansion that are kept in global data (can be accessed from any <code>Ident</code> without any context)<br>
libsyntax_pos/lib.rs - some secondary methods like macro backtrace using primary methods from <a href="http://hygiene.rs" target="_blank" title="http://hygiene.rs">hygiene.rs</a><br>
libsyntax_ext - implementations of built-in macros (including macro attributes and derives) and some other early code generation facilities like injection of standard library imports or generation of test harness.<br>
libsyntax/config.rs - implementation of cfg/cfg_attr (they treated specially from other macros), should probably be moved into libsyntax/ext.<br>
libsyntax/tokenstream.rs + libsyntax/parse/token.rs - structures for compiler-side tokens, token trees, and token streams.<br>
libsyntax/ext - various expansion-related stuff<br>
    libsyntax/ext/base.rs - basic structures used by expansion<br>
    libsyntax/ext/expand.rs - some expansion structures and the bulk of expansion infrastructure code - collecting macro invocations, calling into resolve for them, calling their expanding functions, and integrating the results back into AST<br>
    libsyntax/ext/placeholder.rs - the part of <a href="http://expand.rs" target="_blank" title="http://expand.rs">expand.rs</a> responsible for "integrating the results back into AST" basicallly, "placeholder" is a temporary AST node replaced with macro expansion result nodes<br>
    libsyntax/ext/builer.rs - helper functions for building AST for built-in macros in libsyntax_ext (and user-defined syntactic plugins previously), can probably be moved into libsyntax_ext these days<br>
    libsyntax/ext/proc_macro.rs + libsyntax/ext/proc_macro_server.rs - interfaces between the compiler and the stable <code>proc_macro</code> library, converting tokens and token streams between the two representations and sending them through C ABI<br>
    libsyntax/ext/tt - implementation of <code>macro_rules</code>, turns <code>macro_rules</code> DSL into something with signature <code>Fn(TokenStream) -&gt; TokenStream</code> that can eat and produce tokens, @mark-i-m knows more about this<br>
librustc_resolve/macros.rs - resolving macro paths, validating those resolutions, reporting various "not found"/"found, but it's unstable"/"expected x, found y" errors<br>
librustc/hir/map/def_collector.rs + librustc_resolve/build_reduced_graph.rs - integrate an AST fragment freshly expanded from a macro into various parent/child structures like module hierarchy or "definition paths"</p>
<p>Primary structures:<br>
HygieneData - global piece of data containing hygiene and expansion info that can be accessed from any <code>Ident</code> without any context<br>
ExpnId - ID of a macro call or desugaring (and also expansion of that call/desugaring, depending on context)<br>
ExpnInfo/InternalExpnData - a subset of properties from both macro definition and macro call available through global data<br>
SyntaxContext - ID of a chain of nested macro definitions (identified by <code>ExpnId</code>s)<br>
SyntaxContextData - data associated with the given SyntaxContext, mostly a cache for results of filtering that chain in different ways<br>
Span - a code location + SyntaxContext<br>
Ident - interned string (Symbol) + Span, i.e. a string with attached hygiene data<br>
TokenStream - a collection of <code>TokenTree</code>s<br>
TokenTree - a token (punctuation, identifier, or literal) or a delimited group (anything inside <code>()</code>/<code>[]</code>/<code>{}</code>)<br>
SyntaxExtension - a lowered macro representation, contains its expander function transforming a tokenstream or AST into tokenstream or AST + some additional data like stability, or a list of unstable features allowed inside the macro.<br>
SyntaxExtensionKind - expander functions may have several different signatures (take one token stream, or two, or a piece of AST, etc), this is an enum that lists them<br>
ProcMacro/TTMacroExpander/AttrProcMacro/MultiItemModifier - traits representing the expander signatures (TODO: change and rename the signatures into something more consistent)<br>
trait Resolver - a trait used to break crate dependencies (so resolver services can be used in libsyntax, despite librustc_resolve and pretty much everything else depending on libsyntax)<br>
ExtCtxt/ExpansionData - various intermediate data kept and used by expansion infra in the process of its work<br>
AstFragment - a piece of AST that can be produced by a macro (may include multiple homogeneous AST nodes, like e.g. a list of items)<br>
Annotatable - a piece of AST that can be an attribute target, almost same thing as AstFragment except for types and patterns that can be produced by macros but cannot be annotated with attributes (TODO: Merge into AstFragment)<br>
trait MacResult - a "polymorphic" AST fragment, something that can turn into a different AstFragment depending on its context (aka AstFragmentKind - item, or expression, or pattern etc.)<br>
Invocation/InvocationKind - a structure describing a macro call, these structures are collected by the expansion infra (InvocationCollector), queued, resolved, expanded when resolved, etc.</p>
<p>Primary algorithms / actions:<br>
TODO</p>



<a name="171633628"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171633628" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171633628">(Jul 24 2019 at 19:04)</a>:</h4>
<p>Very useful <span aria-label="+1" class="emoji emoji-1f44d" role="img" title="+1">:+1:</span></p>



<a name="171633807"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171633807" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171633807">(Jul 24 2019 at 19:07)</a>:</h4>
<p><span class="user-mention" data-user-id="123856">@Vadim Petrochenkov</span> Zulip doesn't have an indication of typing, so I'm not sure if you are waiting for me or not</p>



<a name="171633816"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171633816" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171633816">(Jul 24 2019 at 19:07)</a>:</h4>
<p>The TODO part should be about how a crate transitions from the state "macros exist as written in source" to "all macros are expanded", but I didn't write it yet.</p>



<a name="171633895"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171633895" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171633895">(Jul 24 2019 at 19:08)</a>:</h4>
<p>(That should probably better happen off-line.)</p>



<a name="171633910"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171633910" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171633910">(Jul 24 2019 at 19:08)</a>:</h4>
<p>Now, if you have any questions?</p>



<a name="171633941"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171633941" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171633941">(Jul 24 2019 at 19:09)</a>:</h4>
<p>Thanks :)</p>



<a name="171634156"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171634156" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171634156">(Jul 24 2019 at 19:12)</a>:</h4>
<p>/me is still reading :P</p>



<a name="171634300"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171634300" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171634300">(Jul 24 2019 at 19:14)</a>:</h4>
<p>Ok</p>



<a name="171634349"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171634349" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171634349">(Jul 24 2019 at 19:15)</a>:</h4>
<p>So I guess my first question is about hygiene, since that remains the most mysterious to me... My understanding is that the parser outputs AST nodes, where each node has a <code>Span</code></p>



<a name="171634438"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171634438" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171634438">(Jul 24 2019 at 19:16)</a>:</h4>
<p>In the absence of macros and desugaring, what does the syntax context of an AST node look like?</p>



<a name="171634481"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171634481" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171634481">(Jul 24 2019 at 19:16)</a>:</h4>
<p><span class="user-mention" data-user-id="123856">@Vadim Petrochenkov</span></p>



<a name="171634510"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171634510" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171634510">(Jul 24 2019 at 19:17)</a>:</h4>
<p>Not each node, but many of them.<br>
When a node is not macro-expanded, its context is <code>0</code>.</p>



<a name="171634518"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171634518" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171634518">(Jul 24 2019 at 19:17)</a>:</h4>
<p>aka <code>SyntaxContext::empty()</code></p>



<a name="171634572"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171634572" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171634572">(Jul 24 2019 at 19:18)</a>:</h4>
<p>it's a chain that consists of one expansion - expansion <code>0</code> aka <code>ExpnId::root</code>.</p>



<a name="171634621"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171634621" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171634621">(Jul 24 2019 at 19:18)</a>:</h4>
<p>Do all expansions start at <code>root</code>?</p>



<a name="171634624"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171634624" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171634624">(Jul 24 2019 at 19:18)</a>:</h4>
<p>Also, <code>SyntaxContext:empty()</code> is its own father.</p>



<a name="171634660"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171634660" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171634660">(Jul 24 2019 at 19:19)</a>:</h4>
<p>Is this actually stored somewhere or is it a logical value?</p>



<a name="171634668"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171634668" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171634668">(Jul 24 2019 at 19:19)</a>:</h4>
<p>All expansion hyerarchies (there are several of them) start at <code>ExpnId::root</code>.</p>



<a name="171634706"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171634706" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171634706">(Jul 24 2019 at 19:19)</a>:</h4>
<p>Vectors in <code>HygieneData</code> has entries for both ctxt == 0 and expn_id == 0.</p>



<a name="171634824"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171634824" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171634824">(Jul 24 2019 at 19:21)</a>:</h4>
<p>I don't think anyone looks into them much though.</p>



<a name="171634874"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171634874" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171634874">(Jul 24 2019 at 19:21)</a>:</h4>
<p>Ok</p>



<a name="171634875"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171634875" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171634875">(Jul 24 2019 at 19:21)</a>:</h4>
<p>Speaking of multiple hierarchies...</p>



<a name="171634974"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171634974" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171634974">(Jul 24 2019 at 19:22)</a>:</h4>
<p>Go ahead :)</p>



<a name="171635017"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171635017" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171635017">(Jul 24 2019 at 19:23)</a>:</h4>
<p>One is parent (expn_id1) -&gt; parent(expn_id2) -&gt; ...</p>



<a name="171635070"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171635070" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171635070">(Jul 24 2019 at 19:23)</a>:</h4>
<p>This is the order in which macros are expanded.</p>



<a name="171635082"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171635082" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171635082">(Jul 24 2019 at 19:24)</a>:</h4>
<p>Well.</p>



<a name="171635146"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171635146" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171635146">(Jul 24 2019 at 19:24)</a>:</h4>
<p>When we are expanding one macro another macro is revealed in its output.</p>



<a name="171635168"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171635168" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171635168">(Jul 24 2019 at 19:24)</a>:</h4>
<p>That's the parent-child relation in this hierarchy.</p>



<a name="171635218"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171635218" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171635218">(Jul 24 2019 at 19:25)</a>:</h4>
<p><code>InternalExpnData::parent</code> is the child-&gt;parent link.</p>



<a name="171635244"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171635244" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171635244">(Jul 24 2019 at 19:25)</a>:</h4>
<p>So in the above chain expn_id1 is the child?</p>



<a name="171635295"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171635295" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171635295">(Jul 24 2019 at 19:26)</a>:</h4>
<p>Yes.</p>



<a name="171635300"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171635300" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171635300">(Jul 24 2019 at 19:26)</a>:</h4>
<p>The second one is parent (SyntaxContext1) -&gt; parent(SyntaxContext2) -&gt; ...</p>



<a name="171635323"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171635323" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171635323">(Jul 24 2019 at 19:26)</a>:</h4>
<p>This is about nested macro <em>definitions</em>.<br>
When we are expanding one macro another macro definition is revealed in its output.</p>



<a name="171635341"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171635341" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171635341">(Jul 24 2019 at 19:27)</a>:</h4>
<p><code>SyntaxContextData::parent</code> is the child-&gt;parent link here.</p>



<a name="171635445"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171635445" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171635445">(Jul 24 2019 at 19:28)</a>:</h4>
<p>So, <code>SyntaxContext</code> is the whole chain in this hierarchy, and <code>outer_expn</code>s are individual elements in the chain.</p>



<a name="171635551"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171635551" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171635551">(Jul 24 2019 at 19:30)</a>:</h4>
<p>So for example, suppose I have the following:</p>
<div class="codehilite"><pre><span></span><span class="n">macro_rules</span><span class="o">!</span><span class="w"> </span><span class="n">foo</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">()</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">println</span><span class="o">!</span><span class="p">();</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">foo</span><span class="o">!</span><span class="p">();</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
</pre></div>


<p>Then AST nodes that are finally generated would have parent(expn_id_println) -&gt; parent(expn_id_foo), right?</p>



<a name="171635569"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171635569" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171635569">(Jul 24 2019 at 19:30)</a>:</h4>
<p>Pretty common construction (at least it was, before refactorings) is <code>SyntaxContext::empty().apply_mark(expn_id)</code>, which means...</p>



<a name="171635594"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171635594" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171635594">(Jul 24 2019 at 19:30)</a>:</h4>
<blockquote>
<p>Then AST nodes that are finally generated would have parent(expn_id_println) -&gt; parent(expn_id_foo), right?</p>
</blockquote>
<p>Yes.</p>



<a name="171635616"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171635616" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171635616">(Jul 24 2019 at 19:31)</a>:</h4>
<blockquote>
<p>and outer_expns are individual elements in the chain.</p>
</blockquote>
<p>Sorry, what is <code>outer_expns</code>?</p>



<a name="171635631"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171635631" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171635631">(Jul 24 2019 at 19:31)</a>:</h4>
<p><code>SyntaxContextData::outer_expn</code></p>



<a name="171635641"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171635641" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171635641">(Jul 24 2019 at 19:31)</a>:</h4>
<p>Thanks :) Please continue</p>



<a name="171635730"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171635730" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171635730">(Jul 24 2019 at 19:32)</a>:</h4>
<p>...which means a token produced by a built-in macro (which is defined in the root effectively).</p>



<a name="171635764"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171635764" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171635764">(Jul 24 2019 at 19:33)</a>:</h4>
<p>Where does the <code>expn_id</code> come from?</p>



<a name="171635774"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171635774" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171635774">(Jul 24 2019 at 19:33)</a>:</h4>
<p>Or a stable proc macro, which are always considered to be defined in the root because they are always cross-crate, and we don't have the cross-crate hygiene implemented, ha-ha.</p>



<a name="171635783"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171635783" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171635783">(Jul 24 2019 at 19:33)</a>:</h4>
<blockquote>
<p>Where does the expn_id come from?</p>
</blockquote>



<a name="171635843"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171635843" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171635843">(Jul 24 2019 at 19:34)</a>:</h4>
<p>ID of the built-in macro call like <code>line!()</code>.</p>



<a name="171635873"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171635873" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171635873">(Jul 24 2019 at 19:34)</a>:</h4>
<p>Assigned continuously from 0 to N as soon as we discover new macro calls.</p>



<a name="171636013"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171636013" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171636013">(Jul 24 2019 at 19:36)</a>:</h4>
<p>Sorry, I didn't quite understand. Do you mean that only built-in macros receive continuous IDs?</p>



<a name="171636042"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171636042" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171636042">(Jul 24 2019 at 19:36)</a>:</h4>
<p>So, the second hierarchy has a catch - the context transplantation hack - <a href="https://github.com/rust-lang/rust/pull/51762#issuecomment-401400732" target="_blank" title="https://github.com/rust-lang/rust/pull/51762#issuecomment-401400732">https://github.com/rust-lang/rust/pull/51762#issuecomment-401400732</a>.</p>



<a name="171636058"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171636058" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171636058">(Jul 24 2019 at 19:37)</a>:</h4>
<blockquote>
<p>Do you mean that only built-in macros receive continuous IDs?</p>
</blockquote>



<a name="171636065"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171636065" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171636065">(Jul 24 2019 at 19:37)</a>:</h4>
<p>No, all macro calls receive ID.</p>



<a name="171636100"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171636100" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171636100">(Jul 24 2019 at 19:37)</a>:</h4>
<p>Built-ins have the typical pattern <code>SyntaxContext::empty().apply_mark(expn_id)</code> for syntax contexts produced by them.</p>



<a name="171636363"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171636363" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171636363">(Jul 24 2019 at 19:41)</a>:</h4>
<p>I see, but this pattern is only used for built-ins, right?</p>



<a name="171636506"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171636506" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171636506">(Jul 24 2019 at 19:43)</a>:</h4>
<p>And also all stable proc macros, see the comments above.</p>



<a name="171636531"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171636531" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171636531">(Jul 24 2019 at 19:43)</a>:</h4>
<p>Got it</p>



<a name="171636587"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171636587" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171636587">(Jul 24 2019 at 19:44)</a>:</h4>
<p>The third hierarchy is call-site hierarchy.</p>



<a name="171636674"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171636674" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171636674">(Jul 24 2019 at 19:45)</a>:</h4>
<p>If <code>foo!(bar!(ident))</code> expands into <code>ident</code></p>



<a name="171636728"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171636728" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171636728">(Jul 24 2019 at 19:45)</a>:</h4>
<p>then hierarchy 1 is root -&gt; foo -&gt; bar -&gt; ident</p>



<a name="171636798"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171636798" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171636798">(Jul 24 2019 at 19:46)</a>:</h4>
<p>but hierarchy 3 is root -&gt; ident</p>



<a name="171636885"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171636885" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171636885">(Jul 24 2019 at 19:47)</a>:</h4>
<p><code>ExpnInfo::call_site</code> is the child-parent link in this case.</p>



<a name="171637061"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171637061" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171637061">(Jul 24 2019 at 19:49)</a>:</h4>
<p>When we expand, do we expand <code>foo</code> first or <code>bar</code>? Why is there a hierarchy 1 here? Is that <code>foo</code> expands first and it expands to something that contains <code>bar!(ident)</code>?</p>



<a name="171637097"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171637097" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171637097">(Jul 24 2019 at 19:50)</a>:</h4>
<p>Ah, yes, let's assume both foo and bar are identity macros.</p>



<a name="171637181"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171637181" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171637181">(Jul 24 2019 at 19:50)</a>:</h4>
<p>Then <code>foo!(bar!(ident))</code> -&gt; expand -&gt; <code>bar!(ident)</code> -&gt; expand -&gt; <code>ident</code></p>



<a name="171637259"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171637259" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171637259">(Jul 24 2019 at 19:51)</a>:</h4>
<p>If <code>bar</code> were expanded first, that would be eager expansion - <a href="https://github.com/rust-lang/rfcs/pull/2320" target="_blank" title="https://github.com/rust-lang/rfcs/pull/2320">https://github.com/rust-lang/rfcs/pull/2320</a>.</p>



<a name="171637345"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171637345" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171637345">(Jul 24 2019 at 19:52)</a>:</h4>
<p>And after we expand only <code>foo!</code> presumably whatever intermediate state has heirarchy 1 of root-&gt;foo-&gt;(bar_ident), right?</p>



<a name="171637350"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171637350" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171637350">(Jul 24 2019 at 19:52)</a>:</h4>
<p>(We have it hacked into some built-in macros, but not generally.)</p>



<a name="171637373"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171637373" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171637373">(Jul 24 2019 at 19:52)</a>:</h4>
<blockquote>
<p>And after we expand only foo! presumably whatever intermediate state has heirarchy 1 of root-&gt;foo-&gt;(bar_ident), right?</p>
</blockquote>



<a name="171637384"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171637384" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171637384">(Jul 24 2019 at 19:53)</a>:</h4>
<p>Yes.</p>



<a name="171637414"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171637414" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171637414">(Jul 24 2019 at 19:53)</a>:</h4>
<p>Got it :)</p>



<a name="171637759"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171637759" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171637759">(Jul 24 2019 at 19:56)</a>:</h4>
<p>It looks like we have ~5 minutes left. This has been very helpful already, but I also have more questions. Shall we try to schedule another meeting in the future?</p>



<a name="171637803"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171637803" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171637803">(Jul 24 2019 at 19:57)</a>:</h4>
<p>Sure, why not.</p>



<a name="171637927"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171637927" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171637927">(Jul 24 2019 at 19:58)</a>:</h4>
<p>A thread for offline questions-answers would be good too.</p>



<a name="171638181"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171638181" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171638181">(Jul 24 2019 at 20:01)</a>:</h4>
<blockquote>
<p>A thread for offline questions-answers would be good too.</p>
</blockquote>
<p>I don't mind using this thread, since it already has a lot of info in it. We also plan to summarize the info from this thread into the rustc-guide.</p>
<blockquote>
<p>Sure, why not.</p>
</blockquote>
<p>Unfortunately, I'm unavailable for a few weeks. Would August 21-ish work for you (and <span class="user-group-mention" data-user-group-id="1380">@WG-learning</span> )?</p>



<a name="171638198"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171638198" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171638198">(Jul 24 2019 at 20:01)</a>:</h4>
<p><span class="user-mention" data-user-id="123856">@Vadim Petrochenkov</span> Thanks very much for your time and knowledge!</p>



<a name="171638257"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171638257" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171638257">(Jul 24 2019 at 20:02)</a>:</h4>
<p>One last question: are there more hierarchies?</p>



<a name="171638339"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171638339" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171638339">(Jul 24 2019 at 20:03)</a>:</h4>
<p>Not that I know of.<br>
Three + the context transplantation hack is already more complex than I'd like.</p>



<a name="171638438"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171638438" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171638438">(Jul 24 2019 at 20:04)</a>:</h4>
<p>Yes, one wonders what it would be like if one also had to think about eager expansion...</p>



<a name="171638888"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171638888" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171638888">(Jul 24 2019 at 20:09)</a>:</h4>
<p>sorry but I couldn't follow that much today, will read it when I have some time later</p>



<a name="171638891"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/171638891" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#171638891">(Jul 24 2019 at 20:09)</a>:</h4>
<p>btw <a href="https://github.com/rust-lang/rustc-guide/issues/398" target="_blank" title="https://github.com/rust-lang/rustc-guide/issues/398">https://github.com/rust-lang/rustc-guide/issues/398</a></p>



<a name="172622866"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/172622866" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#172622866">(Aug 06 2019 at 19:52)</a>:</h4>
<p><span class="user-mention" data-user-id="123856">@Vadim Petrochenkov</span> Would 7pm UTC on August 21 work for a followup?</p>



<a name="172625015"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/172625015" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#172625015">(Aug 06 2019 at 20:21)</a>:</h4>
<p>Tentatively yes.</p>



<a name="173402443"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173402443" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173402443">(Aug 16 2019 at 19:50)</a>:</h4>
<p><span class="user-mention" data-user-id="123856">@Vadim Petrochenkov</span> <span class="user-group-mention" data-user-group-id="1380">@WG-learning</span>  Does this still work for everyone?</p>



<a name="173432762"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173432762" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173432762">(Aug 17 2019 at 08:25)</a>:</h4>
<p>August 21 is still ok.</p>



<a name="173820204"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173820204" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173820204">(Aug 21 2019 at 18:30)</a>:</h4>
<p><span class="user-group-mention" data-user-group-id="1380">@WG-learning</span> <span class="user-mention" data-user-id="123856">@Vadim Petrochenkov</span> We will start in ~30min</p>



<a name="173821022"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173821022" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173821022">(Aug 21 2019 at 18:40)</a>:</h4>
<p>Oh.<br>
Thanks for the reminder, I forgot about this entirely.</p>



<a name="173822673"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173822673" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173822673">(Aug 21 2019 at 19:00)</a>:</h4>
<p>Hello!</p>



<a name="173822718"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173822718" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173822718">(Aug 21 2019 at 19:00)</a>:</h4>
<p>(I'll be here in a couple of minutes.)</p>



<a name="173823107"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173823107" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173823107">(Aug 21 2019 at 19:06)</a>:</h4>
<p>Ok, I'm here.</p>



<a name="173823113"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173823113" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173823113">(Aug 21 2019 at 19:06)</a>:</h4>
<p>Hi :)</p>



<a name="173823123"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173823123" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173823123">(Aug 21 2019 at 19:06)</a>:</h4>
<p>Hi.</p>



<a name="173823126"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173823126" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173823126">(Aug 21 2019 at 19:06)</a>:</h4>
<p>so last time, we talked about the 3 context heirarchies</p>



<a name="173823140"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173823140" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173823140">(Aug 21 2019 at 19:06)</a>:</h4>
<p>Right.</p>



<a name="173823262"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173823262" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173823262">(Aug 21 2019 at 19:08)</a>:</h4>
<p>Was there anything you wanted to add to that? If not, I think it would be good to get a big-picture... Given some piece of rust code, how do we get to the point where things are expanded and hygiene context is computed?</p>



<a name="173823288"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173823288" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173823288">(Aug 21 2019 at 19:09)</a>:</h4>
<p>(I'm assuming that hygiene info is computed as we expand stuff, since I don't think you can discover it beforehand)</p>



<a name="173823317"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173823317" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173823317">(Aug 21 2019 at 19:09)</a>:</h4>
<p>Ok, let's move from hygiene to expansion.</p>



<a name="173823387"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173823387" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173823387">(Aug 21 2019 at 19:10)</a>:</h4>
<p>Especially given that I don't remember the specific hygiene algorithms like <code>adjust</code> in detail.</p>



<a name="173823457"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173823457" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173823457">(Aug 21 2019 at 19:11)</a>:</h4>
<blockquote>
<p>Given some piece of rust code, how do we get to the point where things are expanded </p>
</blockquote>
<p>So, first of all, the "some piece of rust code" is the whole crate.</p>



<a name="173823472"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173823472" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173823472">(Aug 21 2019 at 19:11)</a>:</h4>
<p>Just to confirm, the algorithms are well-encapsulated, right? Like a function or a struct as opposed to a bunch of conventions distributed across the codebase?</p>



<a name="173823474"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173823474" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173823474">(Aug 21 2019 at 19:11)</a>:</h4>
<p>We run <code>fully_expand_fragment</code> in it.</p>



<a name="173823555"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173823555" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173823555">(Aug 21 2019 at 19:12)</a>:</h4>
<blockquote>
<p>Just to confirm, the algorithms are well-encapsulated, right?</p>
</blockquote>
<p>Yes, the algorithmic parts are entirely inside <code>hygiene.rs</code>.</p>



<a name="173823600"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173823600" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173823600">(Aug 21 2019 at 19:13)</a>:</h4>
<p>Ok, some are in <code>fn resolve_crate_root</code>, but those are hacks.</p>



<a name="173823690"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173823690" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173823690">(Aug 21 2019 at 19:14)</a>:</h4>
<p>(Continuing about expansion.)<br>
If <code>fully_expand_fragment</code> is run <em>not</em> on a whole crate, it means that we are performing eager expansion.</p>



<a name="173823731"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173823731" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173823731">(Aug 21 2019 at 19:15)</a>:</h4>
<p>Eager expansion is done for arguments of some built-in macros that expect literals.</p>



<a name="173823747"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173823747" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173823747">(Aug 21 2019 at 19:15)</a>:</h4>
<p>It generally performs a subset of actions performed by the non-eager expansion.</p>



<a name="173823760"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173823760" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173823760">(Aug 21 2019 at 19:15)</a>:</h4>
<p>So, I'll talk about non-eager expansion for now.</p>



<a name="173823887"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173823887" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173823887">(Aug 21 2019 at 19:17)</a>:</h4>
<p>Eager expansion is not exposed as a language feature, right? i.e. it is not possible for me to write an eager macro?</p>



<a name="173823902"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173823902" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173823902">(Aug 21 2019 at 19:17)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/pull/53778#issuecomment-419224049" target="_blank" title="https://github.com/rust-lang/rust/pull/53778#issuecomment-419224049">https://github.com/rust-lang/rust/pull/53778#issuecomment-419224049</a><br>
(vvv The link is explained below vvv )</p>



<a name="173823937"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173823937" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173823937">(Aug 21 2019 at 19:17)</a>:</h4>
<blockquote>
<p>Eager expansion is not exposed as a language feature, right? i.e. it is not possible for me to write an eager macro?</p>
</blockquote>
<p>Yes, it's entirely an ability of some built-in macros.</p>



<a name="173823985"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173823985" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173823985">(Aug 21 2019 at 19:18)</a>:</h4>
<p>Not exposed for general use.</p>



<a name="173824032"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173824032" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173824032">(Aug 21 2019 at 19:18)</a>:</h4>
<p><code>fully_expand_fragment</code> works in iterations.</p>



<a name="173824204"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173824204" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173824204">(Aug 21 2019 at 19:21)</a>:</h4>
<p>Iterations looks roughly like this:<br>
- Resolve imports in our partially built crate as much as possible.<br>
- Collect as many macro invocations as possible from our partially built crate (fn-like, attributes, derives) from the crate and add them to the queue.</p>



<a name="173824260"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173824260" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173824260">(Aug 21 2019 at 19:21)</a>:</h4>
<ul>
<li>Take a macro from the queue, and attempt to resolve it.</li>
</ul>



<a name="173824335"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173824335" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173824335">(Aug 21 2019 at 19:22)</a>:</h4>
<ul>
<li>If it's resolved - run its expander function that consumes tokens or AST and produces tokens or AST (depending on the macro kind).</li>
</ul>



<a name="173824359"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173824359" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173824359">(Aug 21 2019 at 19:23)</a>:</h4>
<ul>
<li>(If it's not resolved, then put it back into the queue.)</li>
</ul>



<a name="173824386"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173824386" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173824386">(Aug 21 2019 at 19:23)</a>:</h4>
<p>^^^ That's where we fill in the hygiene data associated with <code>ExpnId</code>s.</p>



<a name="173824472"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173824472" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173824472">(Aug 21 2019 at 19:24)</a>:</h4>
<p>When we put it back in the queue?</p>



<a name="173824556"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173824556" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173824556">(Aug 21 2019 at 19:25)</a>:</h4>
<p>or do you mean the collect step in general?</p>



<a name="173824567"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173824567" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173824567">(Aug 21 2019 at 19:25)</a>:</h4>
<p>Once we resolved the macro call to the macro definition we know everything about the macro and can call <code>set_expn_data</code> to fill in its properties in the global data.</p>



<a name="173824592"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173824592" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173824592">(Aug 21 2019 at 19:25)</a>:</h4>
<p>I mean, immediately after successful resolution.</p>



<a name="173824689"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173824689" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173824689">(Aug 21 2019 at 19:26)</a>:</h4>
<p>That's the first part of hygiene data, the second one is associated with <code>SyntaxContext</code> rather than with <code>ExpnId</code>, it's filled in later during expansion.</p>



<a name="173824858"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173824858" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173824858">(Aug 21 2019 at 19:28)</a>:</h4>
<p>So, after we run the macro's expander function and got a piece of AST (or got tokens and parsed them into a piece of AST) we need to integrate that piece of AST into the big existing partially built AST.</p>



<a name="173824949"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173824949" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173824949">(Aug 21 2019 at 19:29)</a>:</h4>
<p>This integration is a really important step where the next things happen:<br>
- <code>NodeId</code>s are assigned.</p>



<a name="173825044"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173825044" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173825044">(Aug 21 2019 at 19:30)</a>:</h4>
<ul>
<li>"def paths"s and their IDs (<code>DefId</code>s) are created</li>
</ul>



<a name="173825132"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173825132" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173825132">(Aug 21 2019 at 19:31)</a>:</h4>
<ul>
<li>Names are put into modules from the resolver point of view.</li>
</ul>



<a name="173825230"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173825230" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173825230">(Aug 21 2019 at 19:32)</a>:</h4>
<p>So, we are basically turning some vague token-like mass into proper set in stone hierarhical AST and side tables.</p>



<a name="173825403"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173825403" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173825403">(Aug 21 2019 at 19:34)</a>:</h4>
<p>Where exactly this happens - <code>NodeId</code>s are assigned by <code>InvocationCollector</code> (which also collects new macro calls from this new AST piece and adds them to the queue), <code>DefId</code>s are created by <code>DefCollector</code>, and modules are filled by <code>BuildReducedGraphVisitor</code>.</p>



<a name="173825457"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173825457" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173825457">(Aug 21 2019 at 19:35)</a>:</h4>
<p>These three passes run one after another on every AST fragment freshly expanded from a macro.</p>



<a name="173825618"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173825618" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173825618">(Aug 21 2019 at 19:37)</a>:</h4>
<p>After expanding a single macro and integrating its output we again try to resolve all imports in the crate, and then return to the big queue processing loop and pick up the next macro.</p>



<a name="173825689"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173825689" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173825689">(Aug 21 2019 at 19:38)</a>:</h4>
<p>Repeat until there's no more macros.</p>



<a name="173825724"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173825724" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173825724">(Aug 21 2019 at 19:38)</a>:</h4>
<hr>



<a name="173825737"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173825737" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173825737">(Aug 21 2019 at 19:38)</a>:</h4>
<p>The integration step is where we would get parser errors too right?</p>



<a name="173825781"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173825781" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173825781">(Aug 21 2019 at 19:39)</a>:</h4>
<p>Also, when do we know definitively that resolution has failed for particular ident?</p>



<a name="173825806"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173825806" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173825806">(Aug 21 2019 at 19:39)</a>:</h4>
<blockquote>
<p>The integration step is where we would get parser errors too right?</p>
</blockquote>
<p>Yes, if the macro produced tokens (rather than AST directly) and we had to parse them.</p>



<a name="173826005"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173826005" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173826005">(Aug 21 2019 at 19:42)</a>:</h4>
<blockquote>
<p>when do we know definitively that resolution has failed for particular ident?</p>
</blockquote>
<p>So, ident is looked up in a number of scopes during resolution.<br>
From closest like the current block or module, to far away like preludes or built-in types.</p>



<a name="173826038"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173826038" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173826038">(Aug 21 2019 at 19:42)</a>:</h4>
<p>If lookup is certainly failed in <em>all</em> of the scopes, then it's certainly failed.</p>



<a name="173826082"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173826082" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173826082">(Aug 21 2019 at 19:43)</a>:</h4>
<p>This is after all expansions and integrations are done, right?</p>



<a name="173826091"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173826091" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173826091">(Aug 21 2019 at 19:43)</a>:</h4>
<p>"Certainly" is determined differently for different scopes, e.g. for a module scope it means no unexpanded macros and no unresolved glob imports in that module.</p>



<a name="173826164"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173826164" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173826164">(Aug 21 2019 at 19:44)</a>:</h4>
<blockquote>
<p>This is after all expansions and integrations are done, right?</p>
</blockquote>
<p>For macro and import names this happens <em>during</em> expansions and integrations.</p>



<a name="173826190"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173826190" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173826190">(Aug 21 2019 at 19:45)</a>:</h4>
<p>Makes sense</p>



<a name="173826197"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173826197" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173826197">(Aug 21 2019 at 19:45)</a>:</h4>
<p>For all other names we certainly know whether a name is resolved successfully or not on the first attempt, because no new names can appear.</p>



<a name="173826220"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173826220" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173826220">(Aug 21 2019 at 19:45)</a>:</h4>
<p>(They are resolved in a later pass, see <code>librustc_resolve/late.rs</code>.)</p>



<a name="173826233"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173826233" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173826233">(Aug 21 2019 at 19:45)</a>:</h4>
<p>And if at the end of the iteration, there are still things in the queue that can't be resolve, this represents an error, right?</p>



<a name="173826285"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173826285" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173826285">(Aug 21 2019 at 19:46)</a>:</h4>
<p>i.e. an undefined macro?</p>



<a name="173826302"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173826302" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173826302">(Aug 21 2019 at 19:46)</a>:</h4>
<p>Yes, if we make no progress during an iteration, then we are stuck and that state represent an error.</p>



<a name="173826349"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173826349" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173826349">(Aug 21 2019 at 19:47)</a>:</h4>
<p>We attempt to recover though, using dummies expanding into nothing or <code>ExprKind::Err</code> or something like that for unresolved macros.</p>



<a name="173826433"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173826433" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173826433">(Aug 21 2019 at 19:48)</a>:</h4>
<p>This is for the purposes of diagnostics, though, right?</p>



<a name="173826452"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173826452" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173826452">(Aug 21 2019 at 19:48)</a>:</h4>
<p>But if we are going through recovery, then compilation must result in an error anyway.</p>



<a name="173826479"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173826479" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173826479">(Aug 21 2019 at 19:49)</a>:</h4>
<p>Yes, that's for diagnostics, without recovery we would stuck at the first unresolved macro or import.</p>



<a name="173826619"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173826619" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173826619">(Aug 21 2019 at 19:50)</a>:</h4>
<hr>
<p>So, about the <code>SyntaxContext</code> hygiene...</p>



<a name="173826662"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173826662" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173826662">(Aug 21 2019 at 19:51)</a>:</h4>
<p>New syntax contexts are created during macro expansion.</p>



<a name="173826778"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173826778" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173826778">(Aug 21 2019 at 19:53)</a>:</h4>
<p>If the token had context <code>X</code> before being produced by a macro, e.g. here <code>ident</code> has context <code>SyntaxContext::root()</code>:</p>



<a name="173826796"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173826796" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173826796">(Aug 21 2019 at 19:53)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="kr">macro</span><span class="w"> </span><span class="n">m</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">ident</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>



<a name="173826903"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173826903" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173826903">(Aug 21 2019 at 19:54)</a>:</h4>
<p>, then after being produced by the macro it has context <code>X -&gt; macro_id</code>.</p>



<a name="173826991"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173826991" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173826991">(Aug 21 2019 at 19:55)</a>:</h4>
<p>I.e. our <code>ident</code> has context <code>ROOT -&gt; id(m)</code> after it's produced by <code>m</code>.</p>



<a name="173827021"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173827021" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173827021">(Aug 21 2019 at 19:56)</a>:</h4>
<p>The "chaining operator" <code>-&gt;</code> is <code>apply_mark</code> in compiler code.</p>



<a name="173827119"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173827119" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173827119">(Aug 21 2019 at 19:57)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="kr">macro</span><span class="w"> </span><span class="n">m</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kr">macro</span><span class="w"> </span><span class="n">n</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="n">ident</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>



<a name="173827219"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173827219" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173827219">(Aug 21 2019 at 19:58)</a>:</h4>
<p>In this example the <code>ident</code> has context <code>ROOT</code> originally, then <code>ROOT -&gt; id(m)</code>, then <code>ROOT -&gt; id(m) -&gt; id(n)</code>.</p>



<a name="173827379"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173827379" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173827379">(Aug 21 2019 at 20:00)</a>:</h4>
<p>Note that these chains are <em>not</em> entirely determined by their last element, in other words <code>ExpnId</code> is not isomorphic to <code>SyntaxCtxt</code>.</p>



<a name="173827401"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173827401" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173827401">(Aug 21 2019 at 20:00)</a>:</h4>
<p>Couterexample:</p>



<a name="173827464"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173827464" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173827464">(Aug 21 2019 at 20:01)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="kr">macro</span><span class="w"> </span><span class="n">m</span><span class="p">(</span><span class="cp">$i</span>: <span class="nc">ident</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kr">macro</span><span class="w"> </span><span class="n">n</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="p">(</span><span class="cp">$i</span><span class="p">,</span><span class="w"> </span><span class="n">bar</span><span class="p">)</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="n">m</span><span class="o">!</span><span class="p">(</span><span class="n">foo</span><span class="p">);</span><span class="w"></span>
</pre></div>



<a name="173827555"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173827555" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173827555">(Aug 21 2019 at 20:02)</a>:</h4>
<p><code>foo</code> has context <code>ROOT -&gt; id(n)</code> and <code>bar</code> has context <code>ROOT -&gt; id(m) -&gt; id(n)</code> after all the expansions.</p>



<a name="173827745"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173827745" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173827745">(Aug 21 2019 at 20:05)</a>:</h4>
<p>Cool :)</p>



<a name="173827761"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173827761" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173827761">(Aug 21 2019 at 20:05)</a>:</h4>
<p>It looks like we are out of time</p>



<a name="173827776"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173827776" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173827776">(Aug 21 2019 at 20:05)</a>:</h4>
<p>Is there anything you wanted to add?</p>



<a name="173827846"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173827846" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173827846">(Aug 21 2019 at 20:06)</a>:</h4>
<p>We can schedule another meeting if you would like</p>



<a name="173827901"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173827901" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173827901">(Aug 21 2019 at 20:07)</a>:</h4>
<p>Yep, 23.06 already.<br>
No, I think this is an ok point to stop.</p>



<a name="173827928"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173827928" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173827928">(Aug 21 2019 at 20:07)</a>:</h4>
<p><span aria-label="+1" class="emoji emoji-1f44d" role="img" title="+1">:+1:</span></p>



<a name="173827934"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173827934" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173827934">(Aug 21 2019 at 20:07)</a>:</h4>
<p>Thanks <span class="user-mention" data-user-id="123856">@Vadim Petrochenkov</span> ! This was very helpful</p>



<a name="173828035"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/173828035" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#173828035">(Aug 21 2019 at 20:09)</a>:</h4>
<p>Yeah, we can schedule another one.<br>
So far it's been like 1 hour of meetings per month? Certainly not a big burden.</p>



<a name="195792583"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/195792583" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#195792583">(Apr 30 2020 at 02:24)</a>:</h4>
<p><span class="user-mention" data-user-id="123856">@Vadim Petrochenkov</span> I'm finally getting around to turning this into a real chapter (sorry for taking so long!)... One question I had is why we have the three expansion hierarchies. Why do we need them? Can you give some examples of how the hygiene data from each hierarchy is used?</p>



<a name="195962507"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/195962507" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Chris Simpkins <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#195962507">(May 01 2020 at 13:50)</a>:</h4>
<p>Plan to read your PR over the weekend Mark. Will be in touch with any comments.  Look forward to learning more about this area.</p>



<a name="196186425"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/196186425" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#196186425">(May 04 2020 at 14:20)</a>:</h4>
<p><span class="user-mention" data-user-id="198054">@mark-i-m</span></p>



<a name="196186456"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/196186456" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#196186456">(May 04 2020 at 14:21)</a>:</h4>
<p>Well, for different many things.</p>



<a name="196186677"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/196186677" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#196186677">(May 04 2020 at 14:22)</a>:</h4>
<p><code>call_site</code> is mostly for diagnostics, macro backtraces are based on it.<br>
It's also used for the "hygiene transplantation hack".</p>



<a name="196187062"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/196187062" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#196187062">(May 04 2020 at 14:25)</a>:</h4>
<p><code>ExpnId::parent</code> is for tracking position of macros in AST and module structures, and also for introducing "time" into macro expansion to prevent paradoxes with macros expanded "later" affecting macros expanded "earlier".</p>



<a name="196187329"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/196187329" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#196187329">(May 04 2020 at 14:27)</a>:</h4>
<p><code>SyntaxContext::parent</code> I don't even remember why it may be needed in isolation, it's more important that the whole "chain" is unique.</p>



<a name="196187631"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/196187631" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#196187631">(May 04 2020 at 14:29)</a>:</h4>
<p>In general, I have most of this stuff out of cache and need to re-learn it every time I return to doing something with hygiene, so I can't help too much right now without spending hours (or perhaps days) on rereading the code.</p>



<a name="196200167"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/196200167" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#196200167">(May 04 2020 at 15:50)</a>:</h4>
<p><span class="user-mention" data-user-id="123856">@Vadim Petrochenkov</span> when you need to go over the code again it would be great if you do a brain dump here and the working group would probably be able to place that into the guide <span aria-label="heart" class="emoji emoji-2764" role="img" title="heart">:heart:</span></p>



<a name="196205726"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros%20discussion/near/196205726" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/macros.20discussion.html#196205726">(May 04 2020 at 16:29)</a>:</h4>
<p><span class="user-mention" data-user-id="123856">@Vadim Petrochenkov</span> Thanks! No worries. I'm just trying to fill out this PR: <a href="https://github.com/rust-lang/rustc-dev-guide/pull/683" title="https://github.com/rust-lang/rustc-dev-guide/pull/683">https://github.com/rust-lang/rustc-dev-guide/pull/683</a></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>